<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel header="Search Bills" >
                        <f:facet name="header" >
                            <h:panelGroup>
                                <h:panelGrid columns="4">
                                    <h:outputLabel value="From Date"/>
                                    <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{searchController.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >
                                        <f:ajax event="dateSelect" execute="tblBills"  render="tblBills toDate fromDate"/>
                                    </p:calendar>
                                    <h:outputLabel value="To Date"/>
                                    <p:calendar styleClass="dateTimePicker" id="toDate" value="#{searchController.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >
                                        <f:ajax event="dateSelect" execute="tblBills"  render="tblBills toDate fromDate"/>
                                    </p:calendar>
                                </h:panelGrid>

                                <h:panelGrid columns="6" >
                                    <h:outputLabel value="Channel Bill No"/>
                                    <h:outputLabel value="Payment Bill No"/>
                                    <h:outputLabel value="Patient Name"/> 
                                    <h:outputLabel value="Speciality"/> 
                                    <h:outputLabel value="Staff Name"/>      
                                    <h:outputLabel value="Charges"/> 
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.billNo}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.insId}" />
                                    <p:inputText autocomplete="off" value="#{searchController.searchKeyword.patientName}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.speciality}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.staffName}" />
                                    <p:inputText autocomplete="off" value="#{searchController.searchKeyword.total}"/>
                                </h:panelGrid>
                                <h:panelGrid columns="3" >
                                    <p:selectBooleanCheckbox value="#{searchController.reportKeyWord.additionalDetails}" itemLabel="Search All" />
                                    <p:commandButton ajax="false" value="Search(Before 2016 04 22)" action="#{searchController.channelPaymentBills()}"/>
                                    <p:commandButton ajax="false" value="Search" action="#{searchController.channelPaymentBillsNew()}"/>
                                    <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                                        <pe:exporter type="xlsx" target="tblBills" fileName="Channel_doc_pay_done"  />
                                    </p:commandButton>
                                </h:panelGrid>
                            </h:panelGroup>
                        </f:facet>


                        <p:dataTable id="tblBills" value="#{searchController.billItems}" var="billItem"  
                                     sortBy="#{billItem.bill.billClass}">
                            <p:column headerText="View Bill" >
                                <p:commandButton action="channel_payment_bill_reprint" value="View" ajax="false" >
                                    <f:setPropertyActionListener value="#{billItem.bill}" target="#{channelSearchController.bill}"/>
                                </p:commandButton>
                            </p:column>
                            <p:column headerText="Payment Bill No" >
                                <h:outputLabel value="#{billItem.bill.insId}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Channel Bill No" >
                                <h:outputLabel value="#{billItem.paidForBillFee.bill.insId}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Specility" >
                                <h:outputLabel value="#{billItem.paidForBillFee.staff.speciality.name}" ></h:outputLabel>
                            </p:column>    
                            <p:column headerText="Doctor" >
                                <h:outputLabel value="#{billItem.paidForBillFee.staff.person.nameWithTitle}" ></h:outputLabel>
                            </p:column>                         
                            <p:column headerText="Paid at"  >
                                <h:outputLabel value="#{billItem.bill.createdAt}" >
                                    <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                </h:outputLabel>
                                <br/>
                                <h:panelGroup rendered="#{billItem.bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{billItem.bill.cancelled}" value="#{billItem.bill.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                    </h:outputLabel>
                                </h:panelGroup>
                            </p:column>  
                            <p:column headerText="Paid by" >
                                <h:outputLabel value="#{billItem.bill.creater.webUserPerson.name}" >                                      
                                </h:outputLabel>
                                <br/>
                                <h:panelGroup rendered="#{billItem.bill.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{billItem.bill.cancelled}" value="#{billItem.bill.cancelledBill.creater.webUserPerson.name}" >                                       
                                    </h:outputLabel>
                                </h:panelGroup>
                            </p:column> 

                            <p:column headerText="Net Value" >
                                <h:outputLabel value="#{billItem.bill.netTotal}" >
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Comments">
                                <h:outputLabel rendered="#{billItem.bill.refundedBill ne null}" value="#{billItem.bill.refundedBill.comments}" >
                                </h:outputLabel>
                                <h:outputLabel  rendered="#{billItem.bill.cancelledBill ne null}" value="#{billItem.bill.cancelledBill.comments}" >
                                </h:outputLabel>
                            </p:column>
                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
